Telegram Group & Telegram Channel
🖥 Необходимо определить делегат и реализовать метод

Итак, вот задание:
определить делегат bool CounterHashSetDelegate(int a) и реализовать метод int Function12(HashSet<int> intSet, CounterHashSetDelegate filter), который возвращает количество элементов из intSet, которые удовлетворяют условию filter.
public static  class 
{
public delegate bool CounterHashSetDelegate(int a);
public static int Function12(HashSet<int> intSet, CounterHashSetDelegate filter)
{

int count = 0;
foreach (int i in intSet)
{
if(filter(i))
count++;
}
return count;
}
}



Давайте сразу к сути, решение может выглядеть так:
public delegate bool CounterHashSetDelegate(int a);

class Program
{
static void Main(string[] args)
{
CounterHashSetDelegate d = IsEvenNum;

Console.WriteLine($"Количество четных элементов:{Function12(new HashSet<int> { 1, 2, 3, 4, 5 }, d)}");

d = IsGreaterThen;

Console.WriteLine($"Количество элементов > 2:{Function12(new HashSet<int> { 1, 2, 3, 4, 5 }, d)}");

Console.ReadKey();
}

public static bool IsEvenNum(int a)
{
return a % 2 == 0;// четное ли число например
}

public static bool IsGreaterThen(int a)
{
return a > 2;//больше ли например
}


public static int Function12(HashSet<int> intSet, CounterHashSetDelegate filter)
{

int count = 0;
foreach (int i in intSet)
{
if (filter(i))
{
count++;
}
}
return count;
}

}

Вот и все дела

@csharp_ci
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/csharp_1001_notes/439
Create:
Last Update:

🖥 Необходимо определить делегат и реализовать метод

Итак, вот задание:
определить делегат bool CounterHashSetDelegate(int a) и реализовать метод int Function12(HashSet<int> intSet, CounterHashSetDelegate filter), который возвращает количество элементов из intSet, которые удовлетворяют условию filter.

public static  class 
{
public delegate bool CounterHashSetDelegate(int a);
public static int Function12(HashSet<int> intSet, CounterHashSetDelegate filter)
{

int count = 0;
foreach (int i in intSet)
{
if(filter(i))
count++;
}
return count;
}
}



Давайте сразу к сути, решение может выглядеть так:
public delegate bool CounterHashSetDelegate(int a);

class Program
{
static void Main(string[] args)
{
CounterHashSetDelegate d = IsEvenNum;

Console.WriteLine($"Количество четных элементов:{Function12(new HashSet<int> { 1, 2, 3, 4, 5 }, d)}");

d = IsGreaterThen;

Console.WriteLine($"Количество элементов > 2:{Function12(new HashSet<int> { 1, 2, 3, 4, 5 }, d)}");

Console.ReadKey();
}

public static bool IsEvenNum(int a)
{
return a % 2 == 0;// четное ли число например
}

public static bool IsGreaterThen(int a)
{
return a > 2;//больше ли например
}


public static int Function12(HashSet<int> intSet, CounterHashSetDelegate filter)
{

int count = 0;
foreach (int i in intSet)
{
if (filter(i))
{
count++;
}
}
return count;
}

}

Вот и все дела

@csharp_ci

BY C# 1001 notes




Share with your friend now:
tg-me.com/csharp_1001_notes/439

View MORE
Open in Telegram


C 1001 notes Telegram | DID YOU KNOW?

Date: |

Telegram and Signal Havens for Right-Wing Extremists

Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.

What is Secret Chats of Telegram

Secret Chats are one of the service’s additional security features; it allows messages to be sent with client-to-client encryption. This setup means that, unlike regular messages, these secret messages can only be accessed from the device’s that initiated and accepted the chat. Additionally, Telegram notes that secret chats leave no trace on the company’s services and offer a self-destruct timer.

C 1001 notes from tr


Telegram C# 1001 notes
FROM USA